-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
P2P: give the protocol handler access to the peer info #302
Conversation
protocol_request_svc: DummyProtocolRequestHandler, | ||
protocol_request_svc_maker: MapErr::new( | ||
Shared::new(DummyProtocolRequestHandler), | ||
tower::BoxError::from, | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This infallible is being wrapped and returned in an error to satisfy trait bounds, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
Co-authored-by: hinto-janai <hinto.janai@protonmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow I forgot to comment this
Cargo.toml
Outdated
tower = { version = "0.4.13", default-features = false } | ||
tower = { git = "https://github.com/Cuprate/tower.git", rev = "6c7faf0", default-features = false } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to fix a bug in tower so until they merge the patch we will need to point to this fork.
pub trait ProtocolRequestHandlerMaker<Z: NetworkZone>: | ||
tower::MakeService< | ||
client::PeerInformation<Z::Addr>, | ||
ProtocolRequest, | ||
MakeError = tower::BoxError, | ||
Service: ProtocolRequestHandler, | ||
Future: Send + 'static, | ||
> + Send | ||
+ 'static | ||
{ | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a new trait alias and updated the others to use trait bounds instead of an extra associated type
/// Changes the protocol request handler maker, which creates the service that handles [`ProtocolRequest`](crate::ProtocolRequest)s | ||
/// to our node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The handshaker now takes a protocol request handler maker instead of just the request hander
protocol_request_svc: DummyProtocolRequestHandler, | ||
protocol_request_svc_maker: MapErr::new( | ||
Shared::new(DummyProtocolRequestHandler), | ||
tower::BoxError::from, | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
What
Changes the p2p crates to allow giving the protocol handler access to the peer info.
Why
It is useful to know the peers sync state when handling protocol requests.
Where
Mainly the handshaker/handshaker builder.
How
Uses the
tower::make::*
stuff, this allows us to provide an async interface for creating request handlers, which is going to be useful for validating core sync data when handshaking is complete